• Importamos las librerías necesarias

In [1]:
import pandas as pd
import matplotlib.pyplot as plt

In [2]:
%matplotlib inline
  • Importamos las librerías creadas para trabajar

In [3]:
import ext_datos as ext
import procesar as pro
import time_plot as tplt
  • Generamos los datasets de todos los días
  • En primer lugar se extraen los datos de todos los archivos de cada día y se genera una lista de tablas separadas por motor

In [4]:
dia1 = ext.extraer_data('dia1')

In [5]:
motoresdia1 = pro.procesar(dia1)

In [6]:
from scipy import integrate
import pandas as pd
import numpy as np

def integrate_method(self, how='trapz', unit='s'):
    '''Numerically integrate the time series.

    @param how: the method to use (trapz by default)
    @return 

    Available methods:
     * trapz - trapezoidal
     * cumtrapz - cumulative trapezoidal
     * simps - Simpson's rule
     * romb - Romberger's rule

    See http://docs.scipy.org/doc/scipy/reference/integrate.html for the method details.
    or the source code
    https://github.com/scipy/scipy/blob/master/scipy/integrate/quadrature.py
    '''
    available_rules = set(['trapz', 'cumtrapz', 'simps', 'romb'])
    if how in available_rules:
        rule = integrate.__getattribute__(how)
    else:
        print('Unsupported integration rule: %s' % (how))
        print('Expecting one of these sample-based integration rules: %s' % (str(list(available_rules))))
        raise AttributeError
    
    result = rule(self.values, self.index.astype(np.int64) / 10**9)
    #result = rule(self.values)
    return result

pd.TimeSeries.integrate = integrate_method

In [7]:
motoresdia1['pot_m1'] = motoresdia1.busCurrent_m1*motoresdia1.busVoltage_m1
motoresdia1['pot_m2'] = motoresdia1.busCurrent_m2*motoresdia1.busVoltage_m2

In [8]:
motoresdia1['pot_total'] = motoresdia1.pot_m1+motoresdia1.pot_m2

In [49]:
motoresdia1.busCurrent_m1.plot()
motoresdia1.busCurrent_m2.plot()


Out[49]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fc78ac08110>

In [38]:
tplt.horam([motoresdia1.pot_m1,motoresdia1.pot_m2,motoresdia1.pot_total],'10:25','10:40')



In [23]:
motoresdia1[['motorRpm_m1','motorRpm_m1','pot_m1', 'pot_m2','pot_total']]['2014-11-13 12:00:00':'2014-11-13 12:15:00']


Out[23]:
motorRpm_m1 motorRpm_m1 pot_m1 pot_m2 pot_total
time
2014-11-13 12:00:00 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:00:00.200000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:00:00.400000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:00:00.600000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:00:00.800000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:00:01 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:00:01.200000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:00:01.400000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:00:01.600000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:00:01.800000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:00:02 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:00:02.200000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:00:02.400000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:00:02.600000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:00:02.800000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:00:03 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:00:03.200000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:00:03.400000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:00:03.600000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:00:03.800000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:00:04 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:00:04.200000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:00:04.400000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:00:04.600000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:00:04.800000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:00:05 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:00:05.200000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:00:05.400000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:00:05.600000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:00:05.800000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
... ... ... ... ... ...
2014-11-13 12:14:55 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:14:55.200000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:14:55.400000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:14:55.600000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:14:55.800000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:14:56 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:14:56.200000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:14:56.400000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:14:56.600000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:14:56.800000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:14:57 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:14:57.200000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:14:57.400000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:14:57.600000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:14:57.800000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:14:58 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:14:58.200000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:14:58.400000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:14:58.600000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:14:58.800000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:14:59 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:14:59.200000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:14:59.400000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:14:59.600000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:14:59.800000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:15:00 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:15:00.200000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:15:00.400000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:15:00.600000 628.478455 628.478455 1117.289752 1122.857684 2240.147436
2014-11-13 12:15:00.800000 628.478455 628.478455 1117.289752 1122.857684 2240.147436

4505 rows × 5 columns


In [26]:
motoresdia1.pot_total.dropna().integrate()/3600


Out[26]:
8439.4795102240605

In [47]:



---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-47-38d9681d2666> in <module>()
----> 1 motoresdia1.drop(motoresdia1.pot_total,0)

/usr/local/lib/python2.7/dist-packages/pandas/core/generic.pyc in drop(self, labels, axis, level, inplace, **kwargs)
   1559                 new_axis = axis.drop(labels, level=level)
   1560             else:
-> 1561                 new_axis = axis.drop(labels)
   1562             dropped = self.reindex(**{axis_name: new_axis})
   1563             try:

/usr/local/lib/python2.7/dist-packages/pandas/core/index.pyc in drop(self, labels)
   2222         mask = indexer == -1
   2223         if mask.any():
-> 2224             raise ValueError('labels %s not contained in axis' % labels[mask])
   2225         return self.delete(indexer)
   2226 

ValueError: labels [ nan  nan  nan ...,  nan  nan  nan] not contained in axis

In [ ]: